using System.Globalization;
using System.Xml.Serialization;

namespace HengTong.Kingdee.WSWMSImportBillFacadeSrvProxyService
{
    /// <summary>
    /// EAS 库存数据信息
    /// </summary>
    [XmlRoot("DataInfo")]
    public class EasInventoryDataInfo
    {
        [XmlElement("DataHead")]
        public EasInventoryDataHead DataHead { get; set; }
    }

    /// <summary>
    /// EAS 库存数据头
    /// </summary>
    public class EasInventoryDataHead
    {
        /// <summary>
        /// 公司组织
        /// </summary>
        [XmlElement("companyOrgUnit")]
        public string CompanyOrgUnit { get; set; }

        /// <summary>
        /// 创建时间（原始字符串）
        /// </summary>
        [XmlElement("createTime")]
        public string CreateTimeString { get; set; }

        /// <summary>
        /// 创建时间（DateTime 类型）
        /// </summary>
        [XmlIgnore]
        public DateTime? CreateTime
        {
            get
            {
                if (string.IsNullOrWhiteSpace(CreateTimeString))
                    return null;
                if (DateTime.TryParseExact(CreateTimeString, "yyyy-MM-dd HH:mm:ss",
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
                    return result;
                return null;
            }
        }

        /// <summary>
        /// 仓储组织
        /// </summary>
        [XmlElement("storageOrgUnit")]
        public string StorageOrgUnit { get; set; }

        /// <summary>
        /// 库位
        /// </summary>
        [XmlElement("location")]
        public string Location { get; set; }

        /// <summary>
        /// 库存状态
        /// </summary>
        [XmlElement("storestatus")]
        public string StoreStatus { get; set; }

        /// <summary>
        /// 当前库存数量
        /// </summary>
        [XmlElement("curStoreQty")]
        public decimal CurStoreQty { get; set; }

        /// <summary>
        /// 最后更新时间（原始字符串）
        /// </summary>
        [XmlElement("lastUpdateTime")]
        public string LastUpdateTimeString { get; set; }

        /// <summary>
        /// 最后更新时间（DateTime 类型）
        /// </summary>
        [XmlIgnore]
        public DateTime? LastUpdateTime
        {
            get
            {
                if (string.IsNullOrWhiteSpace(LastUpdateTimeString))
                    return null;
                if (DateTime.TryParseExact(LastUpdateTimeString, "yyyy-MM-dd HH:mm:ss",
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
                    return result;
                return null;
            }
        }

        /// <summary>
        /// 锁定基本数量
        /// </summary>
        [XmlElement("lockBaseQty")]
        public decimal LockBaseQty { get; set; }

        /// <summary>
        /// 最后更新用户
        /// </summary>
        [XmlElement("lastUpdateUser")]
        public string LastUpdateUser { get; set; }

        /// <summary>
        /// 客户
        /// </summary>
        [XmlElement("customer")]
        public string Customer { get; set; }

        /// <summary>
        /// 仓库
        /// </summary>
        [XmlElement("warehouse")]
        public string Warehouse { get; set; }

        /// <summary>
        /// 辅助属性
        /// </summary>
        [XmlElement("assistProperty")]
        public string AssistProperty { get; set; }

        /// <summary>
        /// 唯一键
        /// </summary>
        [XmlElement("uniqueKey")]
        public string UniqueKey { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [XmlElement("creator")]
        public string Creator { get; set; }

        /// <summary>
        /// 金额
        /// </summary>
        [XmlElement("amount")]
        public decimal Amount { get; set; }

        /// <summary>
        /// 基本单位
        /// </summary>
        [XmlElement("baseUnit")]
        public string BaseUnit { get; set; }

        /// <summary>
        /// 锁定数量
        /// </summary>
        [XmlElement("lockQty")]
        public decimal LockQty { get; set; }

        /// <summary>
        /// 供应商
        /// </summary>
        [XmlElement("supplier")]
        public string Supplier { get; set; }

        /// <summary>
        /// 控制单元
        /// </summary>
        [XmlElement("CU")]
        public string CU { get; set; }

        /// <summary>
        /// 当前库存辅助数量
        /// </summary>
        [XmlElement("curStoreAssistQty")]
        public decimal CurStoreAssistQty { get; set; }

        /// <summary>
        /// 跟踪号
        /// </summary>
        [XmlElement("trackNumber")]
        public string TrackNumber { get; set; }

        /// <summary>
        /// 库存类型
        /// </summary>
        [XmlElement("storetype")]
        public string StoreType { get; set; }

        /// <summary>
        /// 物料
        /// </summary>
        [XmlElement("material")]
        public string Material { get; set; }

        /// <summary>
        /// 基本数量
        /// </summary>
        [XmlElement("baseQty")]
        public decimal BaseQty { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        [XmlElement("unit")]
        public string Unit { get; set; }

        /// <summary>
        /// 项目
        /// </summary>
        [XmlElement("project")]
        public string Project { get; set; }

        /// <summary>
        /// 到期日（原始字符串）
        /// </summary>
        [XmlElement("exp")]
        public string ExpString { get; set; }

        /// <summary>
        /// 到期日（DateTime 类型）
        /// </summary>
        [XmlIgnore]
        public DateTime? Exp
        {
            get
            {
                if (string.IsNullOrWhiteSpace(ExpString))
                    return null;
                if (DateTime.TryParseExact(ExpString, "yyyy-MM-dd",
                    CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
                    return result;
                return null;
            }
        }

        /// <summary>
        /// 辅助单位
        /// </summary>
        [XmlElement("assistUnit")]
        public string AssistUnit { get; set; }

        /// <summary>
        /// 批次
        /// </summary>
        [XmlElement("lot")]
        public string Lot { get; set; }

        /// <summary>
        /// 锁定辅助数量
        /// </summary>
        [XmlElement("lockAssistQty")]
        public decimal LockAssistQty { get; set; }
    }
}

